cmake_minimum_required(VERSION 3.5)

option(LSLAPPS_Benchmarks			"Build benchmark apps"              OFF)
option(LSLAPPS_AppTemplate_cpp_qt	"Build GUI example app"				OFF)
option(LSLAPPS_EGIAmpServer			"Build the EGI (Geodesic) app"      OFF)
option(LSLAPPS_eegoSports			"Build eegoSports app"              OFF)
option(LSLAPPS_LabRecorder			"Build the recorder app"            OFF)
option(LSLAPPS_XDFBrowser			"Build the XDFBrowser app"          OFF)
option(LSLAPPS_Wiimote				"Build the Wiimote app"             OFF)
option(LSLAPPS_OpenVR				"Build the OpenVR app"              OFF)

# Windows-only apps
if(WIN32)
	option(LSLAPPS_BrainVisionRDA	"Build the BrainVisionRDAapp"       OFF)
	option(LSLAPPS_BrainAmpSeries	"Build the BrainAmpSeries app"		OFF)
	option(LSLAPPS_Input			"Build input (keyboard/mouse) apps"	OFF)
	option(LSLAPPS_LiveAmp			"Build the LiveAmp app"             OFF)
	option(LSLAPPS_emotiv			"Build the Emotiv app"				OFF)
	option(LSLAPPS_gNEEDaccess		"Build the g.Tec NEEDaccess app"    OFF)
endif()
set(ManualAddApps "BrainVisionRDA" "LiveAmp" "gNEEDaccess")

# add all Apps the user wants to build
get_cmake_property(appnames CACHE_VARIABLES)
foreach(appvar ${appnames})
	string(REGEX MATCH "^LSLAPPS_.+" isappvar ${appvar})
	if(isappvar)
		string(SUBSTRING ${appvar} 8 -1 appname)
		if(${appvar})
			if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${appname}/CMakeLists.txt")
				if(${appname} IN_LIST ManualAddApps)
				    message(STATUS "Skipping automatic add of ${appvar}")
				else()
					message(WARNING "${appvar} was enabled, but its folder is either nonexistent or not checked out")
				endif()
			else()
				add_subdirectory(${appname})
			endif()
		endif()
	endif()
endforeach()

if(LSLAPPS_BrainVisionRDA)
	add_subdirectory(BrainProducts/BrainVisionRDA)
endif()

if(LSLAPPS_LiveAmp)
    add_subdirectory(BrainProducts/LiveAmp)
endif()

if(LSLAPPS_gNEEDaccess)
    add_subdirectory(g.Tec/g.NEEDaccess)
endif()
